package com.sup.common;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;

/**
 * 用于表示一个操作结果，toJson方法返回该message的JSON字符串
 * 
 * @author SKH
 *
 */
public class Message implements Serializable {
	
	private int total;
	
	private Object data;
	
	private Map<String, Object> map;
	
	public Message(){}
	
	public Message(Object data) {
		super();
		this.data=data;
	}

	public Message(int total, Object data) {
		map = new HashMap<String, Object>();			
		map.put("rows", data);
		map.put("total", total);
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public String toJson(){
		return JSON.toJSONString(map);
	}
	public String writeJson(){
		return JSON.toJSONString(data);
	}
}
